#!/usr/bin/env python
# -*- coding: utf-8 -*-
#code:utf-8
#
# Copyright(C) 2011 SupDo.com
# Licensed under the GUN License, Version 3.0 (the "License");
# 
# File:        filters.py
# Author:      KuKei
# Create Date: 2011-04-22
# Description: 自定义过滤器文件
# Modify Date: 2011-04-22

from django import template

register = template.Library()

@register.filter(name='test')
def test(value, arg):
    return value;

@register.filter(name='pathList')
def pathList(value):
    valuelist = value.split('/')
    pathlist = []
    path = ''
    for e in valuelist:
        if e:
            path += '/'+e
            pathlist.append({'path':path, 'name':e})
    return pathlist

@register.filter(name='mod')
def mod(value, arg):
    return value%arg

@register.filter(name='truncateStr')
def truncateStr(value, arg):
    return value[:arg]
